<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Data mapper pattern</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Data_mapper_pattern"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Data_mapper_pattern rootpage-Data_mapper_pattern skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Data mapper pattern</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p>In <a href="Software_engineering" title="Software engineering">software engineering</a>, the <b>data mapper pattern</b> is an <a href="Architectural_pattern_(computer_science)" class="mw-redirect" title="Architectural pattern (computer science)">architectural pattern</a>. It was named by <a href="Martin_Fowler_(software_engineer)" title="Martin Fowler (software engineer)">Martin Fowler</a> in his 2003 book <i>Patterns of Enterprise Application Architecture</i>.<sup id="cite_ref-1" class="reference"><a href="#cite_note-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> The interface of an object conforming to this pattern would include functions such as Create, Read, Update, and Delete, that operate on objects that represent domain entity types in a data store.
</p><p>A Data Mapper is a <a href="Data_access_layer" title="Data access layer">Data Access Layer</a> that performs bidirectional transfer of data between a persistent data store (often a <a href="Relational_database" title="Relational database">relational database</a>) and an in-memory data representation (the domain layer). The goal of the pattern is to keep the in-memory representation and the persistent data store independent of each other and the data mapper itself. This is useful when one needs to model and enforce strict business processes on the data in the domain layer that do not map neatly to the persistent data store.<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> The layer is composed of one or more mappers (or <a href="Data_Access_Object" class="mw-redirect" title="Data Access Object">Data Access Objects</a>), performing the data transfer. Mapper implementations vary in scope. Generic mappers will handle many different domain entity types; dedicated mappers will handle one or a few.
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Implementations">Implementations</h2></div>
<p>Implementations of the concept can be found in various <a href="Software_framework" title="Software framework">frameworks</a> for many programming environments.
</p>
<div class="mw-heading mw-heading3"><h3 id="Java/.NET">Java/.NET</h3></div>
<ul><li><a href="MyBatis" title="MyBatis">MyBatis</a> persistence framework</li>
<li><a href="Hibernate_(framework)" title="Hibernate (framework)">Hibernate</a> (<a href="NHibernate" title="NHibernate">NHibernate</a>) persistence framework</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Node.js_/_TypeScript">Node.js / TypeScript</h3></div>
<ul><li><a rel="nofollow" class="external text" href="http://bookshelfjs.org/">Bookshelf.js</a> library</li>
<li><a rel="nofollow" class="external text" href="https://typeorm.github.io/">TypeORM</a> library</li>
<li><a rel="nofollow" class="external text" href="https://massivejs.org/">Massive.js</a> library</li>
<li><a rel="nofollow" class="external text" href="https://www.prisma.io/">Prisma</a></li>
<li><a rel="nofollow" class="external text" href="https://vincit.github.io/objection.js/">Objection.js</a> library</li>
<li><a rel="nofollow" class="external text" href="https://mikro-orm.io/">MikroORM</a> library</li>
<li><a rel="nofollow" class="external text" href="https://ldkit.io/">LDkit</a> Object Graph Mapper (OGM) for RDF data sources</li></ul>
<div class="mw-heading mw-heading3"><h3 id="PHP">PHP</h3></div>
<ul><li><a rel="nofollow" class="external text" href="https://github.com/atlasphp/Atlas.Orm">Atlas</a> ORM (data mapper, table data gateway, query builder, and PDO wrapper)<sup id="cite_ref-Atlas_3-0" class="reference"><a href="#cite_note-Atlas-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup></li>
<li><a href="Doctrine_(PHP)" title="Doctrine (PHP)">Doctrine2</a> Object Relational Mapper (ORM) and the Database Abstraction Layer<sup id="cite_ref-Doctorine2_4-0" class="reference"><a href="#cite_note-Doctorine2-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup></li>
<li><a rel="nofollow" class="external text" href="https://github.com/cycle/orm">Cycle</a> ORM (PHP DataMapper ORM and Data Modelling Engine)<sup id="cite_ref-Cycle_5-0" class="reference"><a href="#cite_note-Cycle-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup></li>
<li><a rel="nofollow" class="external text" href="https://github.com/cakephp/orm">CakePHP</a> ORM (PHP DataMapper ORM, query builder, and PDO wrapper)</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Perl">Perl</h3></div>
<ul><li><a rel="nofollow" class="external text" href="https://metacpan.org/dist/DBIx-Class">DBIx</a><sup id="cite_ref-DBIx_6-0" class="reference"><a href="#cite_note-DBIx-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup></li></ul>
<div class="mw-heading mw-heading3"><h3 id="Python">Python</h3></div>
<ul><li><a href="SQLAlchemy" title="SQLAlchemy">SQLAlchemy</a> library</li>
<li><a rel="nofollow" class="external text" href="https://mincepy.readthedocs.io/en/latest/">mincePy</a> library</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Ruby">Ruby</h3></div>
<ul><li><a rel="nofollow" class="external text" href="http://datamapper.org/">DataMapper</a> library (Actually this library implemented the Active Record design pattern, its successor, DataMapper 2 (now <a rel="nofollow" class="external text" href="http://rom-rb.org/">ROM</a>) aimed to actually implement the design pattern it was named after)</li></ul>
<div class="mw-heading mw-heading3"><h3 id="Elixir">Elixir</h3></div>
<ul><li><a rel="nofollow" class="external text" href="https://github.com/elixir-ecto/ecto">Ecto</a> persistence framework</li></ul>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="Active_record_pattern" title="Active record pattern">Active record pattern</a> – Concept in software engineering</li>
<li><a href="Object-relational_mapping" class="mw-redirect" title="Object-relational mapping">Object-relational mapping</a> – Programming technique<span style="display:none" class="category-annotation-with-redirected-description">Pages displaying short descriptions of redirect targets</span></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-1">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFFowler2003" class="citation book cs1">Fowler, Martin (2003). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=FyWZt5DdvFkC&dq=active+record&pg=PT187"><i>Patterns of enterprise application architecture</i></a>. Addison-Wesley. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-0-321-12742-6</bdi>.</cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://www.culttt.com/2014/06/18/whats-difference-active-record-data-mapper">"What's the difference between Active Record and Data Mapper?"</a>.</cite></span>
</li>
<li id="cite_note-Atlas-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-Atlas_3-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://atlasphp.io/">"Atlas ORM – Atlas"</a>.</cite></span>
</li>
<li id="cite_note-Doctorine2-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-Doctorine2_4-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20130721044554/http://www.doctrine-project.org/blog/your-own-orm-doctrine2.html#doctrine2-and-activerecord">"Doctrine2 and ActiveRecord – Doctrine2"</a>. <a href="Doctrine_(PHP)" title="Doctrine (PHP)">Doctrine2</a>. Archived from <a rel="nofollow" class="external text" href="http://www.doctrine-project.org/blog/your-own-orm-doctrine2.html#doctrine2-and-activerecord">the original</a> on 2013-07-21<span class="reference-accessdate">. Retrieved <span class="nowrap">2013-04-02</span></span>.</cite></span>
</li>
<li id="cite_note-Cycle-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-Cycle_5-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://github.com/cycle/orm">"Cycle ORM – Cycle"</a>. <i><a href="GitHub" title="GitHub">GitHub</a></i>.</cite></span>
</li>
<li id="cite_note-DBIx-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-DBIx_6-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://stackoverflow.com/questions/281440/is-there-an-orm-for-perl">"stack overflow – DBIx"</a>.</cite></span>
</li>
</ol></div></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-03-19" href="https://en.wikipedia.org/wiki/?title=Data_mapper_pattern&oldid=1281231142">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>